//引入http模块
const https = require("https")
const url=require("url")
//引用url模块
http.createServer((req, res) => { 
	let urlOBJ = url.parse(req.url)
	res.writeHead(200, {
		"Content-Type": "application/json;charset=utf-8",
		"access-control-allow-origin":"*"
	})
	if (urlOBJ.pathname == '/home') { 
		//在此向百度要数据
		httpget((data) => { 
			http.end(`${data}`)
		})
		res.end(`120`)
	}
	res.end(`12`)
}).listen(3000, () => { 
	console.log("开启服务器");
})
function httpget(callbackHttp) { 
	let data=https.get('url', (res) => { 
			res.on('data', (chunk) => { 
				data += chunk
			})
			res.on('end', () => { 
				callbackHttp(data)
			})
		})
}
